/*
    Copyright (C) 2010-2011 mdis
    
    This file is part of mdis.
    Written by Ketfi-Chérif Mehdi <ketficherif.mehdi@gmail.com>

    mdis is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    mdis is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with mdis.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef _PLUGIN_STRUCT_H
#define _PLUGIN_STRUCT_H

typedef struct plugin_desc
{
	char * device;
	char ** regname;
	uint8_t nregs;
}plugin_desc_t;

typedef struct _instruction
{
	char * inst; /* Instruction name. */
	uint8_t opcode; /* Instruction opcode. */
	uint8_t noperands; /* N operand(s). */
	uint8_t nbytes_per_operand; /* N bytes operand(s). */
	uint8_t op1_type;
	uint8_t op2_type;
	uint8_t ncycles;
}instruction_t;

typedef struct _sfr
{
	char * name;	// SFR name
	uint8_t addr;	// SFR address
}sfr_t;

typedef struct _sbit
{
	char * name;	// SBIT name
	uint8_t addr;	// SBIT address
}sbit_t;

typedef struct _simul
{
	uint8_t data[256];
	uint8_t xdata[32768];
	uint8_t code[32768];
	uint16_t pc;
	uint16_t start_addr;
}simul_t;

typedef struct plugin_sym
{
	uint8_t (*init)( uint8_t * rom , uint16_t nbytes );
	instruction_t * (*disasm)( uint8_t * rom , uint16_t offset );
	/* char * (*regs_mmap) ( uint8_t addr ); */
	simul_t * (*simul) ( void );
	uint8_t * (*get_memcode)( void );
	uint8_t * (*get_memram)( void );
	uint8_t * (*get_memxram)( void );
	uint16_t * (*get_pc)( void );
	uint8_t (*get_reg)(uint8_t reg);
	void (*close)( void );
}plugin_sym_t;

#endif

